<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <link rel="icon" href="*{/images/favicon.ico}" type="image/x-icon" />
  <meta http-equiv="P3P" content="CP='NOI NID'">
  <meta http-equiv="_broadcast_from_" Content="1" />
  <script type="text/javascript" src="*{/js/jquery.js}"></script>
  <script type="text/javascript" src="*{/js/func.js}"></script>
  <script type="text/javascript" src="*{/js/base64.js}"></script>
  <title>数据字典选择表</title>
<style type="text/css">
#table_list_area div {
 margin-top:5px;
}
#table_list_area div span {
  padding-left:10px;
}
</style>
</head>
<body style="margin-left:10px;">
<div id="page_title" style="margin-top:10px;margin-bottom:20px;font-size:20px;font-weight:bold;width:100%;text-align:center;">
  数据字典选择表
</div>
<div style="height:50px;margin-bottom:20px;border:solid 1px #99CCFF;line-height:50px;width:760px;">
  <form id="build_form" method="POST" action="*{/N100112.ha}" target="_blank" style="padding-left:50px;float:left;">
    <input type="hidden" name="source" value="<%=r:source%>"/>
    <textarea name="tables" id="tables" style="display:none;"></textarea>
    数据源主键：<span id="source" style="color:#CC33FF;"><%=r:source%></span>&nbsp;
    数据字典标题：<input type="text" name="title"  style="width:200px;"/>&nbsp;
    <input type="button" value="生成字典"  id="bt_build" style="width:100px;margin-left:20px;background-color:#CCFF00;" onclick="javascript:doBuild();"/>
  </form>
  <div style="clear:both;"></div>
</div>
<div style="margin:10px;width:200px;text-align:center;height:30px;line-height:30px;">
 <input type="checkbox" onclick="javascript:selectAll(this.checked);">全选</input>&nbsp;&nbsp;
 <input type="checkbox" onclick="javascript:disSelected();">反选</input>
</div>
<div id="table_list_area"></div>
<div style="height:30px;"></div>
<a href="#page_title" target="_self">返回顶部</a> 
<div style="height:100px;"></div>
<script type="text/javascript">
function loadTableList(){
  var data = getJson("*{/N100111.ha}","source="+$("#source").text());
  if(data==null){
    alert("没有获取到数据库信息");
    return;
  }
  if(data.status!=1){
    alert(data.msg);
    return;
  }
  data = data.rs;
  
  var area = $("#table_list_area");
  for(var i=0;i<data.length;i++){
   area.append("<div><input type=\"checkbox\" table=\""+data[i][0]+"\"/><span>"+data[i][0]+"</span><span style=\"color:#CCCCCC;\">"+((data[i][1] && data[i][1]!='')?("("+data[i][1]+")"):"")+"</span></div>");
  }
}
loadTableList();

function doBuild(){
 var tableNames = [];
 var boxs = $("#table_list_area").find("input");
 for(var i=0;i<boxs.length;i++){
    if(boxs[i].checked){
      tableNames.push($(boxs[i]).attr("table"));
    }
 }
 if(tableNames.length<1){
   alert("请选择需要生成到字典中的表名");
   return;
 }
 $("#tables").val(tableNames.join());
 $("#build_form")[0].submit();
}

function selectAll(selected){
 var boxs = $("#table_list_area").find("input");
 for(var i=0;i<boxs.length;i++){
    boxs[i].checked = selected;
 }
}

function disSelected(){
 var boxs = $("#table_list_area").find("input");
 for(var i=0;i<boxs.length;i++){
    boxs[i].checked = !boxs[i].checked;
 }
}
</script>
</body>
</html>